#pragma once

using namespace System;

namespace ManagedSail
{

	public ref class SageRectangle
	{
		int x, y, width, height;
		float left, right, bottom, top;

	public:	
		
		SageRectangle() : x(0), y(0), width(0), height(0), 
			left(0.0), right(1.0), bottom(0.0), top(1.0) {}
			
		SageRectangle(float l, float r, float b, float t) 
			: x(0), y(0), width(0), height(0), 
			left(l), right(r), bottom(b), top(t) {}

		SageRectangle(int rx, int ry, int rw, int rh) 
			: x(rx), y(ry), width(rw), height(rh), 
			left(0.0), right(1.0), bottom(0.0), top(1.0) {}
			
		~SageRectangle() {}

		property int X
			{ 
				int get() { return x; }
			}

		property int Y
			{ 
				int get() { return x; }
			}

		property int Width
			{ 
				int get() { return width; }
			}	

		property int Height
			{ 
				int get() { return height; }
			}

		static SageRectangle^ operator+ (SageRectangle^ a, SageRectangle^ b);
		static SageRectangle^ operator/ (SageRectangle^ a, float div);
		static SageRectangle^ operator/ (SageRectangle^ a, SageRectangle^ b);
		static SageRectangle^ operator* (SageRectangle^ a, SageRectangle^ b);
		
		void UpdateBoundary();
		void UpdateBoundary(SageRectangle^ rect);		
		void MoveOrigin(SageRectangle^ rect);
		void Scale(float sx, float sy);
		void Translate(int x, int y);
		void Translate(SageRectangle^ rect);
		void Shrink(float x, float y);
		void Locate();
		void Normalize(SageRectangle^ rect);
		void Normalize(float x, float y);
		
		bool IsOverLap(float l, float r, float b, float t, SageRectangle^ com);
		bool IsOverLapX(float l, float r, SageRectangle^ com);
		bool IsOverLapY(float b, float t, SageRectangle^ com);

		bool IsOverLap(SageRectangle^ rect);	
		bool IsOverLap(SageRectangle^ rect, SageRectangle^ com);
		bool IsOverLapX(int x2, int w2, SageRectangle^ com);
		bool IsOverLapY(int y2, int h2, SageRectangle^ com);

		bool IsInRect(float x, float y);
		bool IsInRect(SageRectangle^ rect);
	};

}
